package com.iran.memento;

public class Main {
    public static void main(String[] args) {
        //需要备份的类
        Originator o = new Originator();
        o.setState("On");

        System.out.println("未备份之前:");
        o.show();
        Caretaker caretaker = new Caretaker();
        caretaker.setMemento(o.createMemento());//保存状态，备份的时候封装好了细节。隐藏了实现过程

        o.setState("off");//改变状态
        o.SetMemento(caretaker.getMemento());//还原
        System.out.println("备份之后：");
        o.show();


    }
}
